<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Vertx::SockJSServer
  
    &mdash; Ruby API Doc
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (S)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Vertx.html" title="Vertx (module)">Vertx</a></span></span>
     &raquo; 
    <span class="title">SockJSServer</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Vertx::SockJSServer
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Vertx::SockJSServer</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">src/main/api_shim/core/sock_js.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    This is an implementation of the server side part of <a href="\"https://github.com/sockjs\"" target="_parent" title="&quot;https://github.com/sockjs&quot;">"https://github.com/sockjs"</a>

SockJS enables browsers to communicate with the server using a simple WebSocket-like api for sending
and receiving messages. Under the bonnet SockJS chooses to use one of several protocols depending on browser
capabilities and what appears to be working across the network.

Available protocols include:

WebSockets
xhr-polling
xhr-streaming
json-polling
event-source
html-file

This means, it should just work irrespective of what browser is being used, and whether there are nasty
things like proxies and load balancers between the client and the server.

For more detailed information on SockJS, see their website.

On the server side, you interact using instances of <span class='object_link'><a href="SockJSSocket.html" title="Vertx::SockJSSocket (class)">SockJSSocket</a></span> - this allows you to send data to the
client or receive data via the <span class='object_link'><a href="ReadStream.html#data_handler-instance_method" title="Vertx::ReadStream#data_handler (method)">ReadStream#data_handler</a></span>.

You can register multiple applications with the same SockJSServer, each using different path prefixes, each
application will have its own handler, and configuration is described in a Hash.

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Author:</p>
<ul class="author">
  
    <li>
      
      
      
      
        
        <div class='inline'><a href="http://tfox.org" target="_parent" title="Tim Fox">Tim Fox</a></div>
      
    </li>
  
</ul>

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#bridge-instance_method" title="#bridge (instance method)">- (Object) <strong>bridge</strong>(config, inbound_permitted, outbound_permitted, auth_timeout = 5*60*1000, auth_address = nil) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (SockJSServer) <strong>initialize</strong>(http_server) </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Create a new SockJSServer.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#install_app-instance_method" title="#install_app (instance method)">- (Object) <strong>install_app</strong>(config, proc = nil, &amp;hndlr) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Install an application.</div></span>
  
</li>

      
    </ul>
  

<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Vertx::SockJSServer (class)">SockJSServer</a></span></tt>) <strong>initialize</strong>(http_server) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Create a new SockJSServer

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>http_server</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="HttpServer.html" title="Vertx::HttpServer (class)">HttpServer</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>You must pass in an instance of <span class='object_link'><a href="HttpServer.html" title="Vertx::HttpServer (class)">HttpServer</a></span></div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


50
51
52</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/sock_js.rb', line 50</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_http_server identifier id'>http_server</span><span class='rparen token'>)</span>
  <span class='rubyid_@j_server ivar id'>@j_server</span> <span class='assign token'>=</span> <span class='rubyid_org identifier id'>org</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_java identifier id'>java</span><span class='dot token'>.</span><span class='rubyid_platform identifier id'>platform</span><span class='dot token'>.</span><span class='rubyid_impl identifier id'>impl</span><span class='dot token'>.</span><span class='rubyid_JRubyVerticleFactory constant id'>JRubyVerticleFactory</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_createSockJSServer identifier id'>createSockJSServer</span><span class='lparen token'>(</span><span class='rubyid_http_server identifier id'>http_server</span><span class='dot token'>.</span><span class='rubyid__to_java_server identifier id'>_to_java_server</span><span class='rparen token'>)</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="bridge-instance_method">
  
    - (<tt>Object</tt>) <strong>bridge</strong>(config, inbound_permitted, outbound_permitted, auth_timeout = 5*60*1000, auth_address = nil) 
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


67
68
69
70
71
72
73</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/sock_js.rb', line 67</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_bridge identifier id'>bridge</span><span class='lparen token'>(</span><span class='rubyid_config identifier id'>config</span><span class='comma token'>,</span> <span class='rubyid_inbound_permitted identifier id'>inbound_permitted</span><span class='comma token'>,</span> <span class='rubyid_outbound_permitted identifier id'>outbound_permitted</span><span class='comma token'>,</span> <span class='rubyid_auth_timeout identifier id'>auth_timeout</span> <span class='assign token'>=</span> <span class='integer val'>5</span> <span class='mult op'>*</span> <span class='integer val'>60</span> <span class='mult op'>*</span> <span class='integer val'>1000</span><span class='comma token'>,</span> <span class='rubyid_auth_address identifier id'>auth_address</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
  <span class='rubyid_j_inbound_permitted identifier id'>j_inbound_permitted</span> <span class='assign token'>=</span> <span class='rubyid_org identifier id'>org</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_java identifier id'>java</span><span class='dot token'>.</span><span class='rubyid_core identifier id'>core</span><span class='dot token'>.</span><span class='rubyid_json identifier id'>json</span><span class='dot token'>.</span><span class='rubyid_JsonArray constant id'>JsonArray</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_inbound_permitted identifier id'>inbound_permitted</span><span class='rparen token'>)</span>
  <span class='rubyid_j_outbound_permitted identifier id'>j_outbound_permitted</span> <span class='assign token'>=</span> <span class='rubyid_org identifier id'>org</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_java identifier id'>java</span><span class='dot token'>.</span><span class='rubyid_core identifier id'>core</span><span class='dot token'>.</span><span class='rubyid_json identifier id'>json</span><span class='dot token'>.</span><span class='rubyid_JsonArray constant id'>JsonArray</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_outbound_permitted identifier id'>outbound_permitted</span><span class='rparen token'>)</span>
  <span class='rubyid_@j_server ivar id'>@j_server</span><span class='dot token'>.</span><span class='rubyid_bridge identifier id'>bridge</span><span class='lparen token'>(</span><span class='rubyid_org identifier id'>org</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_java identifier id'>java</span><span class='dot token'>.</span><span class='rubyid_core identifier id'>core</span><span class='dot token'>.</span><span class='rubyid_json identifier id'>json</span><span class='dot token'>.</span><span class='rubyid_JsonObject constant id'>JsonObject</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_config identifier id'>config</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='rubyid_j_inbound_permitted identifier id'>j_inbound_permitted</span><span class='comma token'>,</span>
                   <span class='rubyid_j_outbound_permitted identifier id'>j_outbound_permitted</span><span class='comma token'>,</span> <span class='rubyid_auth_timeout identifier id'>auth_timeout</span><span class='comma token'>,</span> <span class='rubyid_auth_address identifier id'>auth_address</span><span class='rparen token'>)</span>
  <span class='rubyid_self self kw'>self</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="install_app-instance_method">
  
    - (<tt>Object</tt>) <strong>install_app</strong>(config, proc = nil, &amp;hndlr) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Install an application

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>config</span>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>Configuration for the application</div>
      
    </li>
  
    <li>
      
        <span class='name'>proc</span>
      
      
        <span class='type'>(<tt>Proc</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>nil</tt>)</em>
      
      
        &mdash;
        <div class='inline'>Proc representing the handler</div>
      
    </li>
  
    <li>
      
        <span class='name'>hndlr</span>
      
      
        <span class='type'>(<tt>Block</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>Handler to call when a new <span class='object_link'><a href="SockJSSocket.html" title="Vertx::SockJSSocket (class)">is created</a></span></div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


58
59
60
61
62
63
64
65</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/sock_js.rb', line 58</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_install_app identifier id'>install_app</span><span class='lparen token'>(</span><span class='rubyid_config identifier id'>config</span><span class='comma token'>,</span> <span class='rubyid_proc identifier id'>proc</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_hndlr identifier id'>hndlr</span><span class='rparen token'>)</span>
  <span class='rubyid_hndlr identifier id'>hndlr</span> <span class='assign token'>=</span> <span class='rubyid_proc identifier id'>proc</span> <span class='rubyid_if if_mod kw'>if</span> <span class='rubyid_proc identifier id'>proc</span>
  <span class='rubyid_j_config identifier id'>j_config</span> <span class='assign token'>=</span> <span class='rubyid_org identifier id'>org</span><span class='dot token'>.</span><span class='rubyid_vertx identifier id'>vertx</span><span class='dot token'>.</span><span class='rubyid_java identifier id'>java</span><span class='dot token'>.</span><span class='rubyid_core identifier id'>core</span><span class='dot token'>.</span><span class='rubyid_json identifier id'>json</span><span class='dot token'>.</span><span class='rubyid_JsonObject constant id'>JsonObject</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_config identifier id'>config</span><span class='rparen token'>)</span>
  <span class='rubyid_@j_server ivar id'>@j_server</span><span class='dot token'>.</span><span class='rubyid_installApp identifier id'>installApp</span><span class='lparen token'>(</span><span class='rubyid_j_config identifier id'>j_config</span><span class='rparen token'>)</span> <span class='lbrace token'>{</span> <span class='bitor op'>|</span><span class='rubyid_j_sock identifier id'>j_sock</span><span class='bitor op'>|</span>
    <span class='rubyid_hndlr identifier id'>hndlr</span><span class='dot token'>.</span><span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_SockJSSocket constant id'>SockJSSocket</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_j_sock identifier id'>j_sock</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='rbrace token'>}</span>
  <span class='rubyid_self self kw'>self</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Wed Jul 17 20:30:37 2013 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.6.1 (ruby-1.9.3).
</div>

  </body>
</html>